 //给所有请求头都设置token
 $(document).ajaxSend(function(e,xhr,opt){
    //获取token
    let token = localStorage.getItem("user_token")
    //设置token
    xhr.setRequestHeader("user_token_hander",token)
});
//如果用户没登陆，拦截器会返回错误码
$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status == 401){
        //用户未登录
        location.href = "login.html";
    }
});